<template>
  <el-container class="upload-container animate__animated animate__fadeIn">
    <!-- 左侧侧边栏 -->
    <el-aside width="240px" class="sidebar animate__animated animate__slideInLeft">
      <div class="menu-header">
        <t-icon name="upload" size="24px" />
        <span>内容上传</span>
      </div>
      <el-menu
        :default-active="activeRoute"
        class="menu-list"
        @select="handleSelect"
      >
        <el-menu-item index="/home/upload/article" class="animate__animated animate__fadeInLeft">
          <t-icon name="file" />
          <span>写一篇</span>
          <div class="menu-item-indicator"></div>
        </el-menu-item>
        <el-menu-item index="/home/upload/question" class="animate__animated animate__fadeInLeft" style="animation-delay: 0.1s">
          <t-icon name="help-circle" />
          <span>问一下</span>
          <div class="menu-item-indicator"></div>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <!-- 右侧内容区域 -->
    <el-main class="content animate__animated animate__fadeInRight">
      <router-view v-slot="{ Component }">
        <transition
          enter-active-class="animate__animated animate__fadeIn"
          leave-active-class="animate__animated animate__fadeOut"
          mode="out-in"
        >
          <component :is="Component" />
        </transition>
      </router-view>
    </el-main>
  </el-container>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router';
import { computed } from 'vue';
import 'animate.css';

const router = useRouter();
const route = useRoute();

// 计算当前激活的路由
const activeRoute = computed(() => route.path);

// 处理菜单选择
const handleSelect = (path) => {
  router.push(path);
};
</script>

<style scoped>
.upload-container {
  height: calc(100vh - 10px);
  margin: 5px;
  border-radius: 16px;
  overflow: hidden;
  background-color: #f8fafc;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.sidebar {
  background-color: #ffffff;
  border-right: 1px solid #edf2f7;
  transition: all 0.3s ease;
}

.menu-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: #2d3748;
  border-bottom: 1px solid #edf2f7;
}

.menu-list {
  padding: 16px;
  border-right: none;
}

:deep(.el-menu-item) {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  line-height: 56px;
  margin: 8px 0;
  border-radius: 12px;
  font-size: 16px;
  position: relative;
  overflow: hidden;
}

:deep(.el-menu-item.is-active) {
  background-color: #e6f7ff;
  color: #1890ff;
  font-weight: 500;
}

:deep(.el-menu-item.is-active) .menu-item-indicator {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background-color: #1890ff;
  border-radius: 4px;
}

:deep(.el-menu-item:hover) {
  background-color: #f0f7ff;
  color: #1890ff;
  transform: translateX(5px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.content {
  padding: 32px;
  background-color: #ffffff;
  border-radius: 16px;
  margin: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

/* 添加响应式设计 */
@media screen and (max-width: 768px) {
  .sidebar {
    width: 80px !important;
  }
  
  .menu-header span,
  :deep(.el-menu-item) span {
    display: none;
  }
  
  :deep(.el-menu-item) {
    justify-content: center;
  }
}
</style>